﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;

namespace SampleUnitTestingSolution.PageObject
{
    public class LoginPage
    {
        private IWebDriver driver;

        [FindsBy(How = How.Id, Using = "login")]
        private IWebElement loginField;

        [FindsBy(How = How.Id, Using = "password")]
        private IWebElement passwordField;

        [FindsBy(How = How.Name, Using = "commit")]
        private IWebElement submitButton;

        public LoginPage(IWebDriver driver)
        {
            this.driver = driver;
            PageFactory.InitElements(driver, this);
        }

        public void Open()
        {
            driver.Navigate().GoToUrl("http://demo.bananascrum.com/login");
        }

        public void Login(string username, string passwd)
        {
            loginField.SendKeys(username);
            passwordField.SendKeys(passwd);
            submitButton.Click();
        }
    }
}
